<!--
  module - 系统配置--- 配置项

  @author liuhx 2020-04-28

-->
<template>
  <div>
    <div class="search-bar">
      <div class="base-condition">
        <el-row justify="space-between">
          <el-col :span="12">
            <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal">
              <el-menu-item index="1">全部配置</el-menu-item>
            </el-menu>
          </el-col>
          <el-col :span="12" style="text-align:right;">
            <el-input
              v-model="listQuery.configKey"
              placeholder="请输入配置项键名"
              class="radius-input"
              style="width: 200px;margin-top:7px;"
              @keyup.enter.native="search"
            >
              <i slot="prefix" class="el-input__icon el-icon-search" @click="search" /></el-input>
          </el-col>
        </el-row>
      </div>
    </div>
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>配置项列表<em>（共{{ total }}条记录）</em></span>
      </div>
      <div>
        <el-row>
          <!-- start 列表 -->
          <el-table
            v-loading="listLoading"
            :data="list"
            height="550"
            style="width: 100%"
            :fit="true"
            :header-cell-style="{background:'#eef1f6',color:'#606266'}"
          >
            <el-table-column type="index" width="50" label="#" align="center" />
            <el-table-column label="配置项键名" prop="configKey" :width="200" :show-overflow-tooltip="true" align="center" />
            <el-table-column label="键值" prop="value" :width="400" :show-overflow-tooltip="true" align="center" />
            <el-table-column label="说明" prop="comment" :width="700" :show-overflow-tooltip="true" align="left" />
            <el-table-column label="操作" class-name="small-padding fixed-width" fixed="right" :width="250" align="center">
              <template slot-scope="scope">
                <!-- <el-button type="primary" size="mini" >
                  修改
                </el-button> -->
                <el-link type="primary" size="mini" @click="handleUpdate(scope.row)">
                  修改
                </el-link>
              </template>
            </el-table-column>
          </el-table>
        </el-row>
        <el-row type="flex" justify="end" style="margin-top:15px;">
          <!-- start 分页 -->
          <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" style="text-align:right;" @pagination="querySysConfigList" />
          <!-- end 分页 -->
        </el-row>
      </div>
    </el-card>

  </div>
</template>

<script>

// api
import { querySysConfigList } from '@/api/sys/sysConfig.js'

// 水波纹插件
import waves from '@/directive/waves'
// 分页
import Pagination from '@/components/Pagination' // secondary package based on el-pagination

export default {
  name: 'SysConfig',
  directives: { waves },
  components: { Pagination },
  data() {
    return {
      activeIndex: '1',
      total: 0,
      listLoading: true,
      list: [],
      listQuery: {
        page: 1,
        limit: 10,
        configKey: ''
      }
    }
  },
  created() {
    this.querySysConfigList()
  },
  methods: {
    querySysConfigList() {
      const curVue = this
      querySysConfigList(this.listQuery).then(res => {
        if (res.code === 1) {
          curVue.listLoading = false
          curVue.list = res.data.sysConfigList
          curVue.total = res.data.totalCount
        } else {
          curVue.noticeUtil.errorMsg('配置项获取失败！')
        }
      })
    },
    handleUpdate(curData) {
      console.log(curData)
      this.$router.push({ path: '/plat/platConfig/updateSysConfiguration', query: curData })
    },
    search() {
      this.querySysConfigList()
      console.log('search', this.listQuery.configKey)
    }
  }
}

</script>

<style lang="scss" scoped>
.search-bar{
  position: relative;
  z-index: 2;
  width: 100%;
  .base-condition{
    padding: 0 40px;
    background: #fff;
    box-shadow: 0 2px 4px 0 rgba(0,0,0,.14);
    .el-menu-demo,.el-menu-demo *{
      line-height: 50px;
      height: 50px;

      .el-menu-item{
        padding: 0 8px;
        margin-right: 20px;
      }
    }
  }
  .more-condition{
    position: absolute;
    top: 65px;
    background: #fff;
    width: 100%;
    height: auto;
    padding: 20px 40px;
    box-shadow: 0 2px 4px 0 rgba(0,0,0,.14);
  }
  .query-result{
    margin-top: 5px;
    font-size: 12px;
    color: #4c596e;
    padding: 15px 30px;
    background: #fbfdff;
  }
  .query-result *{
    line-height: 25px;
  }
  .filter-item{
    display: inline-block;
    padding: 0 10px;
    margin-left: 10px;
    border-radius: 12px;
    background: #e5e9f2;
    color: #7f8997;
  }
  .filter-item i{
    margin-left: 5px;
    font-weight: 700;
    cursor: pointer;
  }

}
.radius-input >>> input{
  border-radius: 100px !important;
}
</style>
<style scoped>
.radius-input >>> input{
      border-radius: 100px !important;
    }
</style>

